<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets aggregation information for a given object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.objaggregation.html">Object Aggregation 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.aggregate-methods-by-list.html">aggregate_methods_by_list</a></div>
 <div class="up"><a href="ref.objaggregation.html">Object Aggregation 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.aggregate-info" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">aggregate_info</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0)</p><p class="refpurpose"><span class="refname">aggregate_info</span> &mdash; <span class="dc-title">
   Gets aggregation information for a given object
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.aggregate-info-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>aggregate_info</strong></span>
    ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$object</code></span>
   )</div>

  <p class="para rdfs-comment">
   Gets the aggregation information for the given
   <em><code class="parameter">object</code></em>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.aggregate-info-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">object</code></em></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.aggregate-info-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the aggregation information as an associative array of arrays of
   methods and properties. The key for the main array is the name of the
   aggregated class.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.aggregate-info-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5027">
    <p><strong>Example #1 Using <span class="function"><strong>aggregate_info()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Slicer&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</span><span style="color: #0000BB">$vegetable</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">Slicer</span><span style="color: #007700">(</span><span style="color: #0000BB">$vegetable</span><span style="color: #007700">)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">vegetable&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$vegetable</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">slice_it</span><span style="color: #007700">(</span><span style="color: #0000BB">$num_cuts</span><span style="color: #007700">)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Doing&nbsp;some&nbsp;simple&nbsp;slicing\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">$num_cuts</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;do&nbsp;some&nbsp;slicing<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />class&nbsp;</span><span style="color: #0000BB">Dicer&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</span><span style="color: #0000BB">$vegetable</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</span><span style="color: #0000BB">$rotation_angle&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">90</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;degrees<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">Dicer</span><span style="color: #007700">(</span><span style="color: #0000BB">$vegetable</span><span style="color: #007700">)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">vegetable&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$vegetable</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">dice_it</span><span style="color: #007700">(</span><span style="color: #0000BB">$num_cuts</span><span style="color: #007700">)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Cutting&nbsp;in&nbsp;one&nbsp;direction\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">$num_cuts</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;do&nbsp;some&nbsp;cutting<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">rotate</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">rotation_angle</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Cutting&nbsp;in&nbsp;a&nbsp;second&nbsp;direction\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">$num_cuts</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;do&nbsp;some&nbsp;more&nbsp;cutting<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">rotate</span><span style="color: #007700">(</span><span style="color: #0000BB">$deg</span><span style="color: #007700">)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Now&nbsp;rotating&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">vegetable</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$deg</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;degrees\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">_secret_super_dicing</span><span style="color: #007700">(</span><span style="color: #0000BB">$num_cuts</span><span style="color: #007700">)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;so&nbsp;secret&nbsp;we&nbsp;cannot&nbsp;show&nbsp;you&nbsp;;-)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />}<br /><br /></span><span style="color: #0000BB">$obj&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Slicer</span><span style="color: #007700">(</span><span style="color: #DD0000">'onion'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">aggregate</span><span style="color: #007700">(</span><span style="color: #0000BB">$obj</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Dicer'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">aggregate_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$obj</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
      </div>

      <div class="example-contents"><p>以上例程会输出：</p></div>
      <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [dicer] =&gt; Array
        (
            [methods] =&gt; Array
                (
                    [0] =&gt; dice_it
                    [1] =&gt; rotate
                )

            [properties] =&gt; Array
                (
                    [0] =&gt; rotation_angle
                )

        )

)
</pre></div>
    </div>
   </div>
   As you can see, all properties and methods of the 
   <strong class="classname">Dicer</strong> class have been aggregated
   into our new object, with the exception of the class
   constructor and the method <span class="methodname"><strong>_secret_super_dicing()</strong></span>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.aggregate-info-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.aggregate.html" class="function" rel="rdfs-seeAlso">aggregate()</a> - Dynamic class and object aggregation of methods and properties</span></li>
    <li class="member"><span class="function"><a href="function.aggregate-methods.html" class="function" rel="rdfs-seeAlso">aggregate_methods()</a> - Dynamic class and object aggregation of methods</span></li>
    <li class="member"><span class="function"><a href="function.aggregate-methods-by-list.html" class="function" rel="rdfs-seeAlso">aggregate_methods_by_list()</a> - Selective dynamic class methods aggregation to an object</span></li>
    <li class="member"><span class="function"><a href="function.aggregate-methods-by-regexp.html" class="function" rel="rdfs-seeAlso">aggregate_methods_by_regexp()</a> - Selective class methods aggregation to an object using a regular
   expression</span></li>
    <li class="member"><span class="function"><a href="function.aggregate-properties.html" class="function" rel="rdfs-seeAlso">aggregate_properties()</a> - Dynamic aggregation of  class properties to an object</span></li>
    <li class="member"><span class="function"><a href="function.aggregate-properties-by-list.html" class="function" rel="rdfs-seeAlso">aggregate_properties_by_list()</a> - Selective dynamic class properties aggregation to an object</span></li>
    <li class="member"><span class="function"><a href="function.aggregate-properties-by-regexp.html" class="function" rel="rdfs-seeAlso">aggregate_properties_by_regexp()</a> - Selective class properties aggregation to an object using a regular
   expression</span></li>
    <li class="member"><span class="function"><a href="function.deaggregate.html" class="function" rel="rdfs-seeAlso">deaggregate()</a> - Removes the aggregated methods and properties from an object</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.objaggregation.html">Object Aggregation 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.aggregate-methods-by-list.html">aggregate_methods_by_list</a></div>
 <div class="up"><a href="ref.objaggregation.html">Object Aggregation 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
